<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>用户展示列表</title>
</head>
<body>

   <a href="#">显示用户列表</a>
   <table border="1" width="1000" height="100" style="text-align:center">
   	   <tr>
   	   	   <td>用户名</td>
   	   	   <td>密码</td>
   	   	   <td>邮箱</td>
   	   	   <td>性别</td>
   	   	   <td>年龄</td>
   	   	   <td>联系方式</td>
   	   	   <td>家庭地址</td>
   	   	   <td>状态</td>
   	   	   <td>操作</td>
   	   </tr>
	
		<tbody id="list">
			
			<!-- 展示用户列表 -->

		</tbody>

   </table>

</body>
</html>
<script type="text/javascript" src="__PUBLIC__/js/jquery-2.1.0.js"></script>
<script type="text/javascript">
    //接收数据，展示在页面
    var url = '{:U("get_user_list")}';
    var data = {};

    $.post(url,data,function(res){
        var html = '';

        //拼接字符串，循环展示模板
        for(var i=0;i<res.length;i++){
            html += '<tr>';
            html += '<td>'+res[i].user_name+'</td>';
            html += '<td>'+res[i].user_pass+'</td>';
            html += '<td>'+res[i].user_email+'</td>';
            html += '<td>'+res[i].user_sex+'</td>';
            html += '<td>'+res[i].user_age+'</td>';
            html += '<td>'+res[i].user_phone+'</td>';
            html += '<td>'+res[i].user_address+'</td>'; 
            html += '<td>'+res[i].status+'</td>'; 
            html += '<td user_id='+res[i].id+'><a class="updata act" status="1" href="/index.php/Admin/User/user_update?id='+res[i].id+'">修改</a>　<a class="del act" status="0">删除</a>　<a class="not act" status="-1">禁用</a>　<a class="yes act" status="1">启用</a></td>';            
            html += '</tr>';
        }

        $('#list').append(html);
    });


    //删除、禁用
    $(document).on('click','.act',undefined,function(){
    	//获取user_id
    	var user_id = $(this).parent().attr('user_id');
    	var url = '{:U("change_status")}';
    	var status = $(this).attr('status');

    	var data = {
    		'status':status,
    		'id':user_id,
    	}

    	$.post(url,data,function(res){
    		alert(res.msg);
    		window.location.reload();

    	});

    });


	
</script>




























